package leetcode.array;

/**
 * @author wangmaolin1
 * @date 2024/3/11 21:52
 */
public class _27移除元素 {
    public int removeElement(int[] nums, int val) {
        if (nums == null || nums.length <= 0) {
            return 0;
        }
        int res = -1;
        int p = 0;
        while (p<nums.length){
            if(nums[p]==val){
                p++;
                continue;
            }
            nums[++res]=nums[p++];
        }
        return res+1;
    }

}
